from django.db import models

# Create your models here.

# 用户表
class User(models.Model):
    name = models.CharField(max_length=200)
    password = models.CharField(max_length=200)

    class Meta:
        db_table = 'user'

# 产品表
class Good(models.Model):
    name = models.CharField(max_length=200)
    img = models.ImageField()
    price = models.DecimalField(max_digits=10,decimal_places=2)
    count = models.IntegerField(default=0)
    class Meta:
        db_table = 'good'
# 详情表
class Detail(models.Model):
    uid = models.ForeignKey(User, on_delete=models.CASCADE)
    gid = models.ForeignKey(Good, on_delete=models.CASCADE)
    count = models.CharField(max_length=200)

    class Meta:
        db_table = 'detail'


# 订单表
class Ding(models.Model):
    # time = models.DateTimeField()

    uid = models.ForeignKey(User,on_delete=models.CASCADE)
    gid = models.ForeignKey(Good,on_delete=models.CASCADE)
    did = models.ForeignKey(Detail,on_delete=models.CASCADE)
    class Meta:
        db_table = 'ding'

